From 670fc47d71d5ecc41e7e6b950ddd55130a4ecf27 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 24 Oct 2014 08:48:00 -0700 Subject: [PATCH] Propagate configuration parser errors Closes #743 --- src/cargo/util/config.rs | 10 ++-------- tests/test_cargo_compile.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index 0cf39c770..e0a57e040 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -255,7 +255,7 @@ pub fn all_configs(pwd: Path) -> CargoResult(pwd: &Path, fn walk_tree(pwd: &Path, walk: |File| -> CargoResult<()>) -> CargoResult<()> { let mut current = pwd.clone(); - let mut err = false; loop { let possible = current.join(".cargo").join("config"); if possible.exists() { let file = try!(File::open(&possible)); - match walk(file) { - Err(_) => err = false, - _ => () - } + try!(walk(file)); } - - if err { return Err(internal("")); } if !current.pop() { break; } } diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index afb48727d..6de108de4 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -1684,3 +1684,29 @@ test!(ignore_bad_directories { assert_that(foo.process(cargo_dir().join("cargo")).arg("build"), execs().with_status(0)); }) + +test!(bad_cargo_config { + let foo = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.0" + authors = [] + "#) + .file("src/lib.rs", "") + .file(".cargo/config", r#" + this is not valid toml + "#); + assert_that(foo.cargo_process("build").arg("-v"), + execs().with_status(101).with_stderr("\ +Couldn't load Cargo configuration + +Caused by: + could not parse Toml manifest; path=[..] + +Caused by: + could not parse input TOML +[..].cargo[..]config:2:20-2:21 expected `=`, but found `i` + +")); +}) -- 2.30.2